/********************************************
 * 功能说明: 
 * 模块名称: 
 * 系统名称: 
 * 软件版权: Frank
 * 系统版本: 1.0.0
 * 开发人员: Frank
 * 开发时间: 2019/12/9 11:10
 * 审核人员: 
 * 相关文档: 
 * 修改记录: 修改日期 修改人员 修改说明
 *********************************************/
package com.spring.arch.uaa.model;

import com.spring.arch.common.enums.Gender;
import com.spring.arch.common.jpa.model.AbstractLogicalModel;
import com.spring.arch.common.validator.constraints.Mobile;
import com.spring.arch.uaa.enums.CreateType;
import com.spring.arch.common.enums.Gender;
import com.spring.arch.common.jpa.model.AbstractLogicalModel;
import com.spring.arch.common.validator.constraints.Mobile;
import com.spring.arch.uaa.enums.CreateType;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 * 租户人员信息
 *
 * @author Frank
 * @version 1.0.0.1
 * @since 2019/12/9 11:10
 */
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@Getter
@Setter
@Entity
@Table(name = "tenant_employee", uniqueConstraints = {
        @UniqueConstraint(columnNames = {
                "tenant_id",
                "code"
        })
})
public class TenantEmployee extends AbstractLogicalModel {

    private static final long serialVersionUID = -3570607683666614195L;

    /**
     * 租户
     */
    @NotNull
    @ManyToOne(fetch = FetchType.LAZY)
    private Tenant tenant;

    /**
     * 员工编号
     */
    @NotBlank
    @Size(max = 64)
    @Column(nullable = false)
    private String code;

    /**
     * 人员姓名
     */
    @NotBlank
    @Size(max = 64)
    @Column(nullable = false)
    private String name;

    /**
     * 手机号码
     */
    @NotBlank
    @Size(max = 16)
    @Mobile
    @Column(nullable = false)
    private String mobile;

    /**
     * 性别
     */
    @Enumerated(EnumType.STRING)
    @Column(length = 32)
    private Gender gender;

    /**
     * 邮箱
     */
    @Email
    @Size(max = 64)
    private String email;

    /**
     * 创建类型
     */
    @Enumerated(EnumType.STRING)
    @Column(length = 32)
    private CreateType createType;

    /**
     * 状态(true 在职 false 离职)
     */
    @NotNull
    private boolean status = true;

    /**
     * 照片，多个之间逗号分隔
     */
    @Size(max = 128)
    private String photos;

    public TenantEmployee(@NotNull Tenant tenant,
                          @NotBlank @Size(max = 32) String code,
                          @NotBlank @Size(max = 64) String name,
                          @NotBlank String mobile,
                          Gender gender,
                          @Email @Size(max = 64) String email,
                          @Size(max = 32) String photos) {
        this.tenant = tenant;
        this.code = code;
        this.name = name;
        this.mobile = mobile;
        this.gender = gender;
        this.email = email;
        this.photos = photos;
    }
}
